package com.sentinel.tokenserver;

import com.alibaba.csp.sentinel.cluster.server.ClusterTokenServer;
import com.alibaba.csp.sentinel.cluster.server.SentinelDefaultTokenServer;
import com.alibaba.csp.sentinel.cluster.server.config.ClusterServerConfigManager;
import com.alibaba.csp.sentinel.cluster.server.config.ServerTransportConfig;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.Collections;

@SpringBootApplication
public class TokenServerApplication {

    public static void main(String[] args) throws Exception {
//        SpringApplication.run(TokenServerApplication.class, args);


        System.setProperty("project.name", "sentinel-test");
        System.setProperty("csp.sentinel.dashboard.server", "http://192.168.0.122:8080");
        System.setProperty("csp.sentinel.log.use.pid", "true");

        ClusterServerConfigManager.loadServerNamespaceSet(Collections.singleton("default"));
        ClusterServerConfigManager.loadGlobalTransportConfig(new ServerTransportConfig().setPort(11111).setIdleSeconds(600));

        // Not embedded mode by default (alone mode).
        ClusterTokenServer tokenServer = new SentinelDefaultTokenServer();

        // A sample for manually load config for cluster server.
        // It's recommended to use dynamic data source to cluster manage config and rules.
        // See the sample in DemoClusterServerInitFunc for detail.
        ClusterServerConfigManager.loadGlobalTransportConfig(new ServerTransportConfig()
                .setIdleSeconds(600)
                .setPort(11111));
        ClusterServerConfigManager.loadServerNamespaceSet(Collections.singleton("study-process-server-dev"));

        // Start the server.
        tokenServer.start();


    }





}
